import request from './request'
import type {
  queryCondition,
  rows,
} from '@/views/scheduleSettings/scheduleSetting'

export function queryPlanInfo(data: queryCondition) {
  if (data.dateTime) {
    const startTime = data.dateTime[0]
    const endTime = data.dateTime[1]
    data.startTime = startTime
    data.endTime = endTime
  }
  return request({
    url: '/scheduleSetting/query',
    method: 'post',
    data: data,
  })
}

export function addPlanInfo(data: rows) {
  return request({
    url: '/scheduleSetting/add',
    method: 'post',
    data: data,
  })
}

export function deletePlanInfo(data: number) {
  return request({
    url: '/scheduleSetting/delete?planId=' + data,
    method: 'delete',
  })
}

export function updatePlanInfo(data: rows) {
  return request({
    url: '/scheduleSetting/update',
    method: 'post',
    data: data,
  })
}

export function changeSchedulePlanStatus(data: any) {
  return request({
    url: '/scheduleSetting/change/planStatus',
    method: 'post',
    data: data,
  })
}
